<template>
<!-- 判断对象是否为空 -->
  <div class="base-info" v-if="Object.keys(goods).length !== 0">
    <div class="info-title">{{goods.title}}</div>
    <div class="info-price">
      <span class="new-price">{{goods.newPrice}}</span>
      <span class="old-price">{{goods.oldPrice}}</span>
      <span class="discount" 
            :style="{backgroundColor: goods.discountBgColor}"
            v-if="goods.discount">
        {{goods.discount}}
      </span>
    </div>
    <div class="info-other">
      <span>{{goods.columns[0]}}</span>
      <span>{{goods.columns[1]}}</span>
      <span>{{goods.services[goods.services.length - 1].name}}</span>
    </div>
    <div class="info-service">
      <div class="info-service-item"
           :key="index" 
           v-for="index in goods.services.length - 1"
           v-if="goods.services[index - 1].icon">
        <img :src="goods.services[index - 1].icon" alt="">
        <span>{{goods.services[index - 1].name}}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      }
    }
  }
}
</script>

<style scoped>
  .base-info {
    margin-top: 15px;
    padding: 0 10px;
    color: #999;
    border-bottom: 5px solid #f2f5f8;
  }

  .info-title {
    text-align: justify;
    color: #222;
  }

  .info-price {
    margin-top: 10px;
  }

  .info-price .new-price {
    font-size: 24px;
    color: var(--color-high-text);
  }

  .info-price .old-price {
    margin-left: 5px;
    font-size: 13px;
    text-decoration: line-through;
  }

  .info-price .discount {
    position: relative;
    top: -4px;

    margin-left: 5px;
    padding: 3px 6px;
    border-radius: 8px;
    font-size: 12px;
    color: #fff;
    background-color: var(--color-high-text);
  }

  .info-other {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    line-height: 30px;
    border-bottom: 1px solid rgba(100,100,100,0.1);
    font-size: 13px;
  }

  .info-service {
    display: flex;
    justify-content: space-between;
    line-height: 60px;
  }

  .info-service-item {
    display: flex;
    align-items: center;
  }

  .info-service-item img {
    width: 14px;
    height: 14px;
  }

  .info-service-item span {
    margin-left: 5px;
    font-size: 13px;
    color: #333;
  }
</style>